home *** CD-ROM | disk | FTP | other *** search
- ;*************
- ;* List2HTML *
- ;*************
-
- ; -= ADDITIONAL LIBRARYS REQUIRED =-
-
- ; 1) EFMUILib V1.5 by VIVID Imagination
-
- ; Note: Modifide by me to include MUITrue & MUIFalse
- ; ===== in this programme. Add your own function with
- ; MUITrue=1 & MUIFalse=False (NOTE! MUITrue <> True).
-
- ; 2) romulusrequesterlib
- ; 3) RIAMOSFuncLib V1.36 by Steven Matty
- ; 4) neilsreqtoolslib by Neil O'Rourke
- ; 5) ElmoreDosLib V2.2 by Richard T. Elmore of Headsoft Software
- ; 6) ElmoreFuncsLib by Richard T. Elmore of Headsoft Software
- ; 7) ElmoreHardwareLib by Richard T. Elmore of Headsoft Software
- ; 8) ElmoreMathLib by Richard T. Elmore of Headsoft Software
-
- ; Copy of Steves.res Included
-
- ;*************************************
- ;* Copyright 2000 Steve Turner *
- ;* address: 21 Oxford Close *
- ;* Washingborough *
- ;* Lincoln *
- ;* LN4 1DT *
- ;* UK *
- ;* e-mail : stevet@redhotant.co.uk *
- ;*************************************
-
- ;*************************************
- ;* This Prog. Is FreeWare But Do Not *
- ;* Distribute Amended Copies WithOut *
- ;* Adding Amendment Notes!! *
- ;*************************************
-
- Goto CONSTANTS
- Dc.b "$VER: List2HTML V1.0 (8/7/00)"
- Even
-
- ;-----CONSTANTS----------------------------------------------------
- .CONSTANTS
-
- #OBJECT_ID =0
-
- #MWText =!NEWOBJ ;MUI Object numbers
- #MWStatus =!NEWOBJ
- #MWQuitB =!NEWOBJ
- #MWSpace =!NEWOBJ
- #MWHGrpA =!NEWOBJ
- #MWVGrpA =!NEWOBJ
- #MWin =!NEWOBJ
- #MUIApp =!NEWOBJ
- #MWConvertB =!NEWOBJ
- #CWText =!NEWOBJ
- #CWNoText =!NEWOBJ
- #CWin =!NEWOBJ
- #CWOkB =!NEWOBJ
- #CWHGrpA =!NEWOBJ
- #CWVGrpA =!NEWOBJ
- #CWSlide =!NEWOBJ
-
- #HIGHEST_MUI_OBJECT =!NEWOBJ ;Highest MUI Object Number + 1
-
- #OBJECT_ID =100 ;Workbench needs signal ID's over 100
- ;Don't know if it's fixed in V3.1 or V3.5
-
- ;Application Signal ID's
- #MWClose =#MUIV_Application_ReturnID_Quit
- #Convert =!NEWOBJ
- #CWOk =!NEWOBJ
- #NewCol =!NEWOBJ
-
- #MAXTAGS =10 ;Highest Number Of Tags Required
- #MAXLINE =256 ;Maximum line length
-
- ;-----INCLUDE INSTRUCTIONS-----------------------------------------
-
- ;******************************
- ;* ADJUST THIS TO YOUR SYSTEM *
- ;******************************
-
- INCDIR "Blitzwork:Statements/"
-
- ;-----MACROS-------------------------------------------------------
- .MACROS
-
- INCLUDE "MACRO" ;Get Standard Macros
-
- Macro MUIErr
- CNIF `0=2
- If MUIObjLoc(`1)=0
- x$=`2+"'"
- Goto tellem
- End If
- CELSE
- CERR "Invalid Number of !MUIErr parameters"
- CEND
- End Macro
-
- Macro Pen3
- !ESC+"3"
- End Macro
-
- Macro SE
- "SYSTEM ERROR"+!NL+!NL
- End Macro
-
- Macro Status
- #MWStatus,#MUIA_Text_Contents
- End Macro
-
- Macro NoGadgets
- MUIAddTags `1,#MUIA_Window_CloseGadget,MUIFalse
- MUIAddTags `1,#MUIA_Window_DepthGadget,MUIFalse
- MUIAddTags `1,#MUIA_Window_SizeGadget,MUIFalse
- MUIAddTags `1,#MUIA_Window_DragBar,MUIFalse
- End Macro
-
- ;-----GLOBALS------------------------------------------------------
- .VARS
-
- ;>NEWTYPES
-
- Dim MyTags.TagItem(#MAXTAGS) ;.TagItem= ti_Tag.l : ti_Data.l
- MyTags(0)\ti_Tag = #TAG_DONE,0 ;Start It Empty
-
- Even
- DEFTYPE.s
- ;>STRINGS
-
- ;****************************************
- v$="V1.0" ;CHANGE VERSION HERE
- vd$=" (8/7/00)" ;===================
- ;****************************************
-
- about$=!Pen3+!NL+" Convert Lists to HTML Table "+v$
- about$=about$+!NL+" ===================================="
- about$=about$+!NL+!NL+" "+!Copy+" STEVE TURNER 2000 "+!Copy
- about$=about$+!NL+" e-mail: stevet@redhotant.com"+!NL
- about$=about$+!NL+" ===================================="
- about$=about$+!NL+!NL+" Lists must be a text file in the form of;"
- about$=about$+!NL+" [column 1 content]['tab'[col 2]...['tab'[col n]]] 'newline'"
- about$=about$+!NL+" Minimum line content is 'newline'"
- about$=about$+!NL+" and 'tab'[...'tab']'newline' is OK."
- about$=about$+!NL+" tab=chr$(9) newline=chr$(10) Max line length="+Str$(#MAXLINE)+!NL
- about$=about$+!NL+" Columns do not have to match text but text will always be"
- about$=about$+!NL+" placed in the first column/s. (Unless tabs are provided)"+!NL
- about$=about$+!NL+" No headers of footers must exist in the input file"+!NL+!NL
- x$="" ;General use
- blank$="" ;Empty string
- title$="List 2 HTML" ;Prog title
- err1$=!Centre+!SE+"Failure To Open Window"
- reqtitle$=title$+" Requester" ;Standard Title for error requester
- but$="_OKay" ;Standard Text for button
- stdbody$="Sorry Unable to Open"+!NL+"MUI Object : '"
- ;Standard Text for error requester
- inc$="Blitzwork:Statements/" ;Include Path
- MaxLen inPath$=192 ;Strings for file handling
- MaxLen outPath$=192
- MaxLen inFi$=192
- MaxLen outFi$=192
- MaxLen inTot$=192
- MaxLen outTot$=192
- MaxLen row$=#MAXLINE ;Maximum input file line length
- col$="Number of Columns =" ;window text
- startcol$=" 1 " ;window start text
-
- Dim Help$(#HIGHEST_MUI_OBJECT) ;Text For Help Bubbles
- Help$(#MWQuitB)="Doh!"
- Help$(#MWConvertB)=!Centre+"Convert Text List"+!NLC+"To HTML Table"
- Help$(#MWStatus)="Current Program Status"
- Help$(#CWOkB)=!Centre+"Accept Setting"+!NLC+"And Close Window"
- Help$(#CWSlide)=!Centre+"Adjust Number"+!NLC+"Of Columns"
-
- Even
- DEFTYPE.b
- ;>BYTES
-
- done=False ;Loop terminater
- cdone=False ;Loop terminater
- n=0 ;Loop counter
-
- Even
- DEFTYPE.w
- ;>WORDS
-
- p=0 ;Pointer
-
- Even
- DEFTYPE.f
- ;>FLOATS
-
- Even
- DEFTYPE.q
- ;>QUICKS
-
- Even
- DEFTYPE.l
- ;>LONGS
-
- sigs=0 ;Signal ID
- csigs=0 ;Signal ID
- x=0 ;General use variable
- cols=1 ;Number of columns
-
- ;------------------------------------------------------------------
- .STATEMENTS
- ;------------------------------------------------------------------
-
- ;-= Usefull Statements & Functions =-
-
- ;INCLUDE "NIB_include.bb2" ;Use NewIcon Libary
- ;INCLUDE "EasyButton" ;EasyButton{object.l,label }
- ;INCLUDE "BFWindow" ;BFWindow{ window }
- ;INCLUDE "Draw3dBox" ;Draw3dBox{ x, y, width, height, style }
- ;INCLUDE "FlashText" ;FlashText{ window, x, y, no , text, speed }
- ;INCLUDE "ShowInfo" ;ShowInfo{ directory, icon, screen number }
- ;INCLUDE "SavePaletteFile" ;SavePaletteFile{ bitmap number, filename }
- ;INCLUDE "WOutline" ;WOutline{ x1, y1, x2, y2, hilite, shadow }
- ;INCLUDE "GoNTSC" ;GoNTSC{}
- ;INCLUDE "GoPAL" ;GoPAL{}
- ;INCLUDE "WindowTitle" ;WindowTitle{ window, window title, screen title }
- ;INCLUDE "CleanBorder" ;CleanBorder{ window number }
- ;INCLUDE "CtrlC" ;CtrlC{}
- ;INCLUDE "UnlockWindow" ;UnLockWindow{ window, lock }
- ;INCLUDE "HidePointer" ;HidePointer{ window }
- ;INCLUDE "UsePalette" ;UsePalette{ screen, palette }
- ;INCLUDE "ShowPointer" ;ShowPointer{ window }
- ;INCLUDE "CompareDates" ;CompareDates { file 1, file 2 }
- ;INCLUDE "FileTime" ;FileTime { filename }
- ;INCLUDE "FileDate" ;FileDate { filename }
- INCLUDE "Exist" ;Exist { filename }
- ;INCLUDE "SetComment" ;SetComment { filename, comment }
- ;INCLUDE "ReadComment" ;ReadComment { filename }
- ;INCLUDE "WindowFlags" ;WindowW { window }
- ;INCLUDE "WinMouseX" ;WinMouseX {}
- ;INCLUDE "WinMouseY" ;WinMouseY {}
- ;INCLUDE "SoundTime" ;SoundTime { sound number }
- ;INCLUDE "LockWindow" ;LockWindow { window }
- ;INCLUDE "WBVersion" ;WBVersion {}
- ;INCLUDE "TimerWait" ;TimerWait { seconds, microsecends }
- ;INCLUDE "WindowFillScreen" ;WindowFillScreen { window number, flags, title }
- ;INCLUDE "ReceiveCtrlC" ;ReceiveCtrlC {}
- ;INCLUDE "WBColours" ;ScreenMouseX {}
- ;INCLUDE "Name" ;Name { old filename, new filename}
- ;INCLUDE "ScreenH" ;ScreenH { screen number }
- ;INCLUDE "ScreenW" ;ScreenW { screen number }
- ;INCLUDE "SetProgName" ;SetProgName { new name }
- ;INCLUDE "IsScreenActive" ;IsScreenActive { screen number }
- ;INCLUDE "Unhook" ;Unhook { device: }
- ;INCLUDE "Hookup" ;Hookup { device: }
- ;INCLUDE "GetArg" ;GetArg {}
- ;INCLUDE "OpenShell" ;OpenShell { x, y, width, height, title, flag(s) }
- ;INCLUDE "Del" ;Del { file }
- ;INCLUDE "OSAssign" ;OSAssign { assign name, path, type }
- ;INCLUDE "Value" ;Value { number string }
- ;INCLUDE "ScreenOpened" ;ScreenOpened { screen }
- ;INCLUDE "WindowOpened " ;WindowOpened{ window number }
- ;INCLUDE "RTReq" ;RTReq { title, body text, gadget }
- ;INCLUDE "TitleBarHeight" ;TitleBarHeight { screen }
- ;INCLUDE "CentreWindowX " ;CentreWindowX { width of window }
- ;INCLUDE "CentreWindowY" ;CentreWindowY { height of window }
- ;INCLUDE "ChipSet" ;ChipSet {}
- ;INCLUDE "WFBox" ;WFBox { window, left, width, top, height }
- ;INCLUDE "StripFile" ;StripFile { path & file name }
- ;INCLUDE "LockReq" ;LockReq { title, body, gadget, type }
- ;INCLUDE "ProgsDir" ;ProgsDir {}
- ;INCLUDE "CurrentDir" ;CurrentDir {}
- ;INCLUDE "ProgsName" ;ProgsName {}
- ;INCLUDE "ParentDir" ;ParentDir { directory }
- ;INCLUDE "Memory" ;Memory { type }
- ;INCLUDE "CheckLib" ;CheckLib { library, version }
- ;INCLUDE "PixelLen" ;PixelLen { text }
- ;INCLUDE "StripToDot" ;StripToDot { filename }
- ;INCLUDE "Quoted" ;Quoted { text }
- ;INCLUDE "CreateDir" ;CreateDir { new directory }
- ;INCLUDE "CenterString" ;CenterString { text, window }
- ;INCLUDE "SaveSound" ;SaveSound { sound number, filename }
- ;INCLUDE "SendARexx" ;SendARexx { arexx command }
- INCLUDE "ASLFileRequest" ;ASLFileRequest { title, path, file, pattern }
- ;INCLUDE "Planes2Cols" ;Planes2Cols { number of bitplanes }
- ;INCLUDE "CheckPic" ;CheckPic { picture file }
- ;INCLUDE "PicSafe" ;PicSafe { picture file, type, safety }
- ;INCLUDE "SoundSafe" ;SoundSafe { sound file, safety }
-
- ;------------------------------------------------------------------
-
- .Stat
-
- Statement Stat{s$} ;Update Status
- MUISet !Status,&s$
- End Statement
-
- ;------------------------------------------------------------------
-
- .START
-
- Even
- SetErr:End:End SetErr
- NoCli
- WBStartup
- CloseEd
- WbToScreen 0
-
- .runit
-
- ;Run the prog.
- ;-------------
-
- ;Main window text
- ;----------------
-
- MUINewObject #MWText,!Text,&about$
- !MUIErr{#MWText,"Main Window Text"}
- MUINewObject #MWStatus,!Text,&blank$,!Textframe,!TextBack
- !MUIErr{#MWStatus,"Main Window Status"}
- !Help{#MWStatus}
-
- ;Column window text
- ;------------------
-
- MUINewObject #CWText,!Text,&col$,!FixedFont
- !MUIErr{#CWText,"Column Window Text"}
- MUINewObject #CWNoText,!Text,&startcol$,!FixedFont
- !MUIErr{#CWNoText,"Column Window Number Text"}
-
- ;Create Slider for column window
- ;-------------------------------
-
- MUIAddTags #CWSlide,#MUIA_Slider_Quiet,MUITrue
- MUISlider #CWSlide,1,10,1
- !MUIErr{#CWSlide,"Column winder slider"}
- !Help{#CWSlide}
-
- ;Create simple buttons
- ;---------------------
-
- ;for main window
-
- MUISimpleButton #MWQuitB,"_Quit"
- !MUIErr{#MWQuitB,"Main Window Quit Button"}
- !Help{#MWQuitB}
- MUISimpleButton #MWConvertB,"_Convert"
- !MUIErr{#MWConvertB,"Main Window Convert Button"}
- !Help{#MWConvertB}
-
- ;for column window
-
- MUISimpleButton #CWOkB," _O.K. "
- !MUIErr{#CWOkB,"Column Window OK Button"}
- !Help{#CWOkB}
-
- ;Create space
- ;------------
-
- ;for main window
-
- MUIHVSpace #MWSpace
- !MUIErr{#MWSpace,"Main Window Space"}
- MUISet #MWSpace,#MUIA_HorizWeight,200
-
- ;Creat column window horizontal group
- ;------------------------------------
-
- MUIAddObjsHGroup #CWHGrpA,#CWText,#CWNoText,#CWOkB
- MUICreateHGroup #CWHGrpA
- !MUIErr{#CWHGrpA,"Column Window Horizontal Group"}
-
- ;Create main window horizontal group
- ;-----------------------------------
-
- MUIAddObjsHGroup #MWHGrpA,#MWConvertB,#MWSpace,#MWQuitB
- MUICreateVGroup #MWHGrpA
- !MUIErr{#MWHGrpA,"Main Window Horizontal Group A"}
-
- ;Create column window vertical group
- ;-----------------------------------
-
- MUIAddObjsVGroup #CWVGrpA,#CWHGrpA,#CWSlide
- MUICreateHGroup #CWVGrpA
- !MUIErr{#CWVGrpA,"Column Window Vertical Group"}
-
- ;Create main window Vertical group
- ;---------------------------------
-
- MUIAddObjsVGroup #MWVGrpA,#MWText,#MWHGrpA,#MWStatus
- MUICreateHGroup #MWVGrpA
- !MUIErr{#MWVGrpA,"Main Window Vertical Group A"}
-
- ;Create main window
- ;------------------
-
- MUIAddTags #MWin,#MUIA_Window_Width,!MUIV_Window_Width_Visible{90}
- MUIAddTags #MWin,!TopCentered,!LeftCentered
- MUIAddTags #MWin,#MUIA_Window_Height,!MUIV_Window_Height_Visible{33}
- MUICreateWindow #MWin,title$,"L2HL",#MWVGrpA
- !MUIErr{#MWin,"Main Window"}
-
- ;Create column window
- ;--------------------
-
- MUIAddTags #CWin,!TopMoused,!LeftMoused
- !NoGadgets{#CWin}
- MUICreateWindow #CWin,"","",#CWVGrpA
- !MUIErr{#CWin,"Column Window"}
- MUISet #CWin,#MUIA_Window_ID,0
-
- ;Create Application
- ;------------------
-
- MUIApplicationAuthor "Steve Turner"
- MUIApplicationBase "LIST2HTML"
- MUIApplicationCopyright "(c) 2000 By Steve Turner"
- MUIApplicationTitle "List2HTML"
- MUIApplicationVersion "List2HTML"+v$+vd$
- MUIApplicationDescription "Covert Lists to HTML Table"
- MUIAddApplicationTags #MUIA_Application_Window,MUIObjLoc(#MWin)
- MUIAddApplicationTags #MUIA_Application_Window,MUIObjLoc(#CWin)
- MUICreateApplication
- MUIApplicationObj #MUIApp
- !MUIErr{#MUIApp,"Application"}
-
- ;Set up comunicators
- ;-------------------
-
- ;Main window close gadget or commodity kill
- MUINotifyApp #MWin,#MUIA_Window_CloseRequest,MUITrue,#MWClose
- ;Main window quit button hit
- MUINotifyApp #MWQuitB,!Pushed,#MWClose
- ;main window convert button hit
- MUINotifyApp #MWConvertB,!Pushed,#Convert
- ;Column window OK button hit
- MUINotifyApp #CWOkB,!Pushed,#CWOk
- ;Column window slider moved
- MUINotifyApp #CWSlide,!SlideMove,#NewCol
-
- ;Open main window
- ;----------------
-
- MUIOpenWindow #MWin
- If MUIGet(#MWin,#MUIA_Window_Open)=MUIFalse
- done=True
- x=MUI_RequestA_(MUIObjLoc(#MUIApp),0,0,&reqtitle$,&but$,&err1$,0)
- End If
-
- ;Monitor Input Until Quit By User
- ;--------------------------------
-
- Stat{"Awaiting Your Instructions"} ;Status waiting
- While done=False
- sigs=MUIWaitEvent ;Wait for event
- Select sigs ;And act on it
- Case #MWClose ;Main window closed
- done=True
- Case #Convert ;Convert button pressed
- Stat{"Getting Input File"}
- MUISet #MWin,#MUIA_Window_Sleep,MUITrue
- inTot$=ASLFileRequest{"Input File",inPath$,inFi$,"#?"}
- ;Get input file
- MUISet #MWin,#MUIA_Window_Sleep,MUIFalse
- If inTot$<>"" ;If input file given
- Stat{"Input File : "+inTot$}
- inPath$=PathPart$(inTot$)
- inFi$=FilePart$(inTot$)
- If outPath$="" ;If no Output stored
- outPath$=inPath$ ;use input directory
- End If
- MUISet #MWin,#MUIA_Window_Sleep,MUITrue
- outTot$=ASLFileRequest{"Output File",outPath$,outFi$,"#?"}
- ;Get output file
- MUISet #MWin,#MUIA_Window_Sleep,MUIFalse
- If outTot$<>"" ;If output file given
- outPath$=PathPart$(outTot$)
- outFi$=FilePart$(outTot$)
- Stat{"Convert "+inFi$+" to "+outFi$}
- If Exist{inTot$}>0 ;Must be input file
- If ReadFile(1,inTot$)=True ;And must be able to read it
- FileInput 1
- If Exist{outTot$}>0 ;Backup any existing output file
- If Exist{outTot$+".bak"}>0
- KillFile(outTot$+".bak")
- End If
- x=Rename(outTot$,outTot$+".bak")
- End If
- If WriteFile(2,outTot$)=True ;Must write to output file
- FileOutput 2
- MUISet #MWin,#MUIA_Window_Sleep,MUITrue
- MUIOpenWindow #CWin ;Open window to get number of columns
- While cdone=False ;Keep window open untill users done
- csigs=MUIWaitEvent ;get input
- Select csigs
- Case #NewCol ;Slider has been moved
- cols=MUIGet(#CWSlide,#MUIA_Numeric_Value)
- ;Read new value
- Format "##"
- x$=Str$(cols) ;Turn value into string
- MUISet #CWNoText,#MUIA_Text_Contents,&x$
- ;Print new value in window
- Case #CWOk ;User hit OK button
- MUICloseWindow #CWin ;Close window and get out of this loop
- MUISet #MWin,#MUIA_Window_Sleep,MUIFalse
- cdone=True
- End Select
- Wend
-
- ;Start output file with standard table header tags
- ;-------------------------------------------------
-
- NPrint "<!-- AutoCreated Table with List2HTML -->"
- NPrint "<TABLE BORDER=1>"
- NPrint " <CAPTION>Table</CAPTION>"
- NPrint " <TR>"
- Format "00"
- For n=1 To cols
- NPrint " <TH>Column "+Str$(n)+"</TH>"
- Next
- NPrint " </TR>"
-
- ;Continue for whole of input file
- ;--------------------------------
-
- While NOT Eof(1)
-
- ;Print tag and read in line upto #MAXLINE chars long
- ;---------------------------------------------------
-
- NPrint " <TR>"
- row$=Edit$(#MAXLINE)
-
- ;For each column
- ;---------------
-
- For n=1 To cols
- Stat{row$}
- p=Instr(row$,Chr$(9)) ;Find tab in string
- If p>0 ;If exists
- x$=Left$(row$,p-1) ; Make x$=column content
- If p=Len(row$) ; Chop column off front of row$
- row$=""
- Else
- row$=Mid$(row$,p+1)
- End If
- Else
- x$=row$ ;Make x$=column content
- row$="" ;Chop column off front of row$
- End If
-
- ;Regardless of content of row$, x$ should = Column
- ;content and row$=rest of line, even if we have run
- ;out of text for the column - so add it to file
- ;--------------------------------------------------
-
- NPrint " <TD>"+x$+"</TD>"
- Next
-
- NPrint " </TR>"
- Wend
-
- ;And end with standard table termination tags
- ;--------------------------------------------
-
- NPrint "</TABLE>"
- NPrint "<!-- End of AutoTable -->"
- CloseFile 2 ;Close output file
- Else
- x$="Unable to Open Output File"
- x=MUI_RequestA_(MUIObjLoc(#MUIApp),0,0,&reqtitle$,but$,&x$,0)
- End If
- CloseFile 1 ;Close input file
- Else
- x$="Unable to Open Input File"
- x=MUI_RequestA_(MUIObjLoc(#MUIApp),0,0,&reqtitle$,but$,&x$,0)
- End If
- Else
- x$="Unable to Find Input File"
- x=MUI_RequestA_(MUIObjLoc(#MUIApp),0,0,&reqtitle$,but$,&x$,0)
- End If
- End If
- End If
- Stat{"Done"} ;Done a loop set status
- End Select
- Wend
-
- ;Cleanup
- ;-------
-
- MUIRemoveApplication
- Free Screen 0
-
- ;And Done
- ;--------
-
- End
-
- .tellem
-
- ;Report MUI Object open error
- ;----------------------------
-
- Window 0,0,0,10,10,#BORDERLESS,"",0,0
- x=EasyRequest(0,reqtitle$,stdbody$+x$,but$)
- Free Window 0
- Free Screen 0
- End
-
- ;------END---------------------------------------------------------
-
-